package com.kyzh.core.utils

import android.graphics.Color
import android.graphics.LinearGradient
import android.graphics.Shader
import android.widget.TextView

fun TextView.setShader(  int: ArrayList<String>){
    when {
        int.size>1 -> {
            var intArray = IntArray(int.size)
            int?.forEachIndexed { index, s ->
                intArray[index] = Color.parseColor(s)
            }
            paint.shader = LinearGradient(
                0f,
                0f,
                0f,
                height.toFloat(),
                intArray,
                null,
                Shader.TileMode.CLAMP
            )
        }
        int.size==1 -> {
            setTextColor(Color.parseColor(int[0]))
            paint.shader = null
        }
        else -> {
             setTextColor(Color.parseColor("#333333"))
             paint.shader = null
        }
    }
}